<template>
  <el-form :model="weightForm">
    <el-col
      :span="14"
      class="el-col-offset-2"
    ><el-input-number
      v-model="weightForm.val"
      :controls="false"
      :disabled="true"
      clearable
    /></el-col>
  </el-form>
</template>

<script>

export default {
  name: 'WeightExtraInput',
  props: {
    index: {
      type: Number,
      required: true
    },
    num: {
      type: Number,
      required: true
    },
    tableWeight: {
      type: Number,
      required: false,
      default: function() {
        return 0
      }
    }
  },
  data() {
    return {
      weightForm: {
        val: ''
      }
    }
  },
  mounted() {
    if (this.tableWeight !== 0) {
      this.weightForm.val = this.tableWeight
    }
  },
  methods: {
    deleteItem() {
      const vm = this
      vm.$emit('delete', vm.index)
    },
    getData() {
      const vm = this
      return vm.weightForm.val
    },
    getIndex() {
      const vm = this
      return vm.index
    },
    setData(data) {
      const vm = this
      vm.weightForm.val = data
    }
  }
}
</script>

<style scoped>
</style>
